<template>
    <div>
        <div class="kehu">
        <van-icon name="arrow-left" @click="$router.go(-1)"/>
        <h2>选择客户</h2>
        <van-icon name="wap-home-o" />
        </div>
        <van-search
  v-model="value"
  show-action
   shape="round"
  placeholder="请输入搜索关键词"
  @search="onSearch"
>
  <template #action>
    <div @click="onSearch">搜索</div>
  </template>
</van-search>
<div class="kehulieb">
    <ul>
        <li v-for="(item,index) in Xuanzerecords" :key="index" @click="tiaozhuan(item.custName,item.id)">
            <div>
                <img src="../../assets/头像男 拷贝 4.png" alt="">
                <span>{{item.custName}}</span>
            </div>
              <van-icon name="arrow" />
        </li>
    </ul>
</div>
    </div>
</template>

<script>
import {GetCustDate} from "@/request/api"
export default {
    data () {
        return {
           value:'',
           Xuanzerecords:null
        }
    },
    methods:{
        onSearch(){
           GetCustDate({
          keyword:this.value,
          current:'1',
          size:'20'
        }).then((res)=>{
            this.Xuanzerecords=res.data.data.records
          console.log("选择客户成功数据:",res);
        }) 
        },
        tiaozhuan(val,id){
        //    console.log(val);
          
           this.$router.push({name:'Newvisitinformation',params:{name:val,id:id}})
        }
    },
    created(){
        GetCustDate({
          keyword:'',
          current:'1',
          size:'20'
        }).then((res)=>{
            this.Xuanzerecords=res.data.data.records
          console.log("选择客户成功数据:",res);
        }) 
    }
}
</script>
 
<style lang = "less" scoped>
    .kehu{
        height: .5rem;
        line-height: .5rem;
        background: #0a3399;
        display: flex;
        font-size: .14rem;
        align-items: center;
        color: white;
        padding: 0 .15rem;
        h2{
            flex: 1;
            text-align: center;
        }
    }
    .kehulieb{
       
        font-size: .15rem;
        background: #fff;
        ul{
            li{
                 display: flex;
                 align-items: center;
                 padding: .15rem;
                 div{
                     display: flex;
                      align-items: center;
                      flex: 1;
                     img{
                         width: .8rem;
                     }
                     span{
                         margin-left: .2rem;
                     }
                 }
            }
        }
    }
</style>